import { useVisible } from "./VisibleProvider";
import style from "./Button.module.css";

export default function Button() {
  const {
    isButtonVisible: visible,
    toggleButtonVisible,
    toggleDialogVisible,
  } = useVisible();

  function openDialog() {
    toggleButtonVisible(false);
    toggleDialogVisible(true);
  }

  if (!visible) return null;

  return (
    <button type="button" className={style.button} onClick={openDialog}>
      试用 AI
    </button>
  );
}
